Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snake_case rename support for Type macro #261

Merged
merged 1 commit into from
Apr 18, 2020

Conversation

shssoichiro
Copy link
Contributor

I encountered a use case while converting a project
from Diesel to sqlx, where I had a custom Postgres enum
which included a snake case field name:

pub enum JobStatus {
    NotRun,
    Finished,
    Failed,
}

Which translates to:

CREATE TYPE job_status AS ENUM ('not_run', 'finished', 'failed');

This is likely to be a semi-common use case,
so this commit adds snake case support for enums
via the #[sqlx(rename_all = "snake_case")] attribute.

I encountered a use case while converting a project
from Diesel to sqlx, where I had a custom Postgres enum
which included a snake case field name:

```rust
pub enum JobStatus {
    NotRun,
    Finished,
    Failed,
}
```

Which translates to:

```sql
CREATE TYPE job_status AS ENUM ('not_run', 'finished', 'failed');
```

This is likely to be a semi-common use case,
so this commit adds snake case support for enums
via the `#[sqlx(rename_all = "snake_case")]` attribute.
@mehcode
Copy link
Member

mehcode commented Apr 18, 2020

Simple uncontroversial addition. 👍 And I still chuckle whenever I see the heck crate.

@mehcode mehcode merged commit 230eeef into launchbadge:master Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants